{include file="public/toper" /}
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">商品管理</a>
        <a><cite>商品信息</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
        <div class="layui-row">
            <div class="layui-form layui-col-md12 x-so">
              <div class="layui-input-inline">
                  <select name="goods_id" lay-filter="aihao" id="selectGood">
                      <option value="">请选择商品</option>
                      {volist name="goods" id="vo"}
                         <option value="{$vo.goods_id}">{$vo.name}</option>
                      {/volist}
                  </select>
              </div>
              <button class="layui-btn"  lay-submit="" lay-filter="sreach"  id="search"><i class="layui-icon">&#xe615;</i></button>
            </div>
        </div>
        <table class="layui-hide" id="test"></table>
    </div>
    <script type="text/html" id="image">
        <img src="{{d.thumbnail_img}}" class="thumb" thumb="{{ d.thumbnail_img }}"/>
    </script>
    <!-- <script type="text/html" id="thumbnailImg">
        <img src="{{d.thumbnail_img}}">
    </script> -->
    <script type="text/html" id="sort">
        <input style="width: 100%" type="text" class="menu-sort j-ajax-input" name="sort" onkeyup="value=value.replace(/[^\d]/g,'')" value="{{d.sort}}" data-value="{{d.sort}}" data-href="{:url('Goods/goodsSort')}?table=goods&id={{d.goods_id}}">
    </script>
    <script type="text/html" id="switchTpl">
        <input type="checkbox" name="shelves" value="{{ d.shelves }}" lay-skin="switch" lay-filter="switchStatus" lay-text="上架|下架" {{ d.shelves == 1 ? 'checked' : '' }} data-href="{:url('Goods/chooseShelves')}?table=goods&id={{ d.goods_id }}">
    </script>

    <script type="text/html" id="barDemo">
          <a title="商品详情" class="layui-btn layui-btn-xs" onclick="x_admin_show('商品详情','/merchant/Goods/goodsDetail?id={{d.goods_id}}')" href="javascript:;" lay-event="edit">商品详情</a>
          <a title="商品库存" class="layui-btn layui-btn-xs" onclick="x_admin_show('商品库存','/merchant/Goods/goodsStore?id={{d.goods_id}}','800')" href="javascript:;">商品库存</a>
    </script>
    
    <script>
        layui.use('table', function(){
            var table = layui.table
            ,form = layui.form
            ,$ = layui.jquery;
          
            var tableIn = table.render({
                method: 'post',
                elem: '#test'
                ,url:"{:url('Goods/goodsList')}"
                ,cellMinWidth: 80
                ,cols: [[
                    {type:'numbers'}
                    ,{field:'name', width:200,title:'商品名称', align:'center'}
                    ,{field:'price', width:180, title:'价格', align:'center'}
                    ,{field:'method', width:150, title:'计价方式', align:'center'}
                    ,{title: '缩略图',width:'150',align: 'center',templet: '#image'}
                    ,{field:'sort', title:'默认排序', align:'center',width:100,toolbar:'#sort'}
                    ,{field:'sale_type', width:180, title: '是否租赁',align: 'center',templet: function(d){
                        if(d.sale_type==2){
                            return '是';
                        }else if(d.sale_type==1){
                            return '不是';
                        }
                    }}
                    ,{field:'shelves', width:180, title:'上下架', align:'center',templet:'#switchTpl'}
                    ,{fixed: 'right', title:'操作', width:180, align:'center', toolbar: '#barDemo',templet:'#changeStore'} //这里的toolbar值是模板元素的选择器
                ]]
                ,page: true
            });

            //搜索
            $('#search').on('click', function () {
                var goods_id = $('#selectGood option:selected').val();
                tableIn.reload({
                    where: {goods_id: goods_id}
                });
            });
            
        });
    </script>
  </body>

</html>